<template>
  <a-card :bordered="false">
    <detail-list title="导师信息">
      <detail-list-item term="导师编号">{{ teacherInfo.gh }}&emsp;</detail-list-item>
      <detail-list-item term="姓名">{{ teacherInfo.xm }}&emsp;</detail-list-item>
      <detail-list-item term="性别">{{ teacherInfo.xbmc }}&emsp;</detail-list-item>
      <detail-list-item term="院系">{{ teacherInfo.ssyxmc }}&emsp;</detail-list-item>
      <detail-list-item term="专业">{{ teacherInfo.zymc }}&emsp;</detail-list-item>
      <detail-list-item term="身份证号">{{ sfzjh }}&emsp;
         <a-button v-if="isShow[0].one" type="primary" size="small" @click="seeNumber(teacherInfo.sfzjh,1)">
              查看
            </a-button>
            <a-button v-if="!isShow[0].one" type="primary" size="small" @click="hideNumberZjhm(teacherInfo.sfzjh)">
              隐藏
            </a-button>
      </detail-list-item>
      <detail-list-item term="出生日期">{{ teacherInfo.csrq && teacherInfo.csrq.format('YYYY-MM-DD') }}&emsp;</detail-list-item>
      <detail-list-item term="职称">{{ teacherInfo.zcmc }}&emsp;</detail-list-item>
      <detail-list-item term="手机号码">{{ lxdh }}&emsp;
        <a-button v-if="isShow[1].two" type="primary" size="small" @click="seeNumber(teacherInfo.lxdh,2)">
              查看
            </a-button>
            <a-button v-if="!isShow[1].two" type="primary" size="small" @click="hideNumberLxdh(teacherInfo.lxdh)">
              隐藏
            </a-button>
      </detail-list-item>
      <detail-list-item term="电子邮箱">{{ teacherInfo.dzxx }}&emsp;</detail-list-item>
      <detail-list-item term="固定电话">{{ teacherInfo.zzdh }}&emsp;</detail-list-item>
    </detail-list>
    <a-row>
      <span style="color:rgba(0,0,0,.85)">研究方向：</span>{{ teacherInfo.yjfx }}
    </a-row>
    <a-row style="text-align: center;">
      <a-button type="primary" @click="$router.back()">返回</a-button>
      <a-button type="primary" @click="exportPdf">打印</a-button>
    </a-row>
  </a-card>
</template>

<script>
import DetailList from '~/tool/DetailList'
const DetailListItem = DetailList.Item

export default {
  data () {
    return {
      teacherInfo: {},
      sfzjh: '',
      lxdh: '',
      gnlxrdh: '',
      isShow: [{one:true},{two:true}],
    }
  },
  components: {
    DetailList,
    DetailListItem
  },
  created () {
    this.$api.overseas.teacherInfo({dsbh: this.$route.params.dsbh}).then(res => {
      this.teacherInfo = res.data
      this.hideNumberZjhm(this.teacherInfo.sfzjh)
      this.hideNumberLxdh(this.teacherInfo.lxdh)
    })
  },
  methods: {
    exportPdf () {
      let fileName = this.teacherInfo.xm + '_导师详细信息.pdf'
      this.$downloadPdf('/xn/dsxx/dsPirnt/' + this.teacherInfo.gh, {}, fileName)
    },
    seeNumber(num,n){
      console.log(num)
        if(n == 1){
          this.sfzjh = num
          this.isShow[0].one = false
        }else if(n == 2){
          this.lxdh = num
          this.isShow[1].two = false
        }else{
          this.gnlxrdh = num
          this.isShow[2].three = false
        }
      },
      hideNumberZjhm(num){
        let arr = []
          arr = num.split('').map((item,index) => {
            if( index > 5 ){
              return item.replace(item,'*')
            }
            return item
          })
          this.sfzjh = arr.join('')
          this.isShow[0].one = true
      },
      hideNumberLxdh(num){
        let arr = []
          arr = num.split('').map((item,index) => {
            if(index > 2){
              return item.replace(item,'*')
            }
            return item
          })
          this.lxdh = arr.join('')
          this.isShow[1].two = true
      },
  }
}
</script>

<style>

</style>
